﻿<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page language="java" import="com.wuliu.model.sys.User" %>
<%@ page language="java" import="com.wuliu.util.BaseUtil" %>
<%@ page language="java" import="com.wuliu.model.common.PageVO" %>
<%@ page language="java" import="com.wuliu.model.common.QueryVO" %>
<%@ page language="java" import="java.util.Map.Entry" %>  
<%
	String path = request.getContextPath();
	String flag = (String)request.getAttribute("flag");
    HashMap<String,String> hmSearch = (HashMap<String,String>)request.getAttribute("hmSearch"); 
	List<?> qList =  (List<?>)request.getAttribute("qList");
	if(qList==null)
		qList = new ArrayList();
%>
<!DOCTYPE html>
<html>
<head>
    <title>网豆物流平台-菜单管理</title>
    <link href="<%=path %>/web/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
	<link href="<%=path %>/web/zTree_v3-master/css/zTreeStyle/zTreeStyle.css" rel="stylesheet" type="text/css"/>
    <link href="<%=path %>/web/css/colorbox.css" rel="stylesheet" type="text/css"  />
    <link href="<%=path %>/web/css/style.css" rel="stylesheet" type="text/css"  />
    <script src="<%=path %>/web/js/jquery-1.11.1.min.js"></script>
    <script src="<%=path %>/web/js/jquery.colorbox-min.js"></script>
    <script src="<%=path %>/web/zTree_v3-master/js/jquery.ztree.core.js"></script>
    <script src="<%=path %>/web/zTree_v3-master/js/jquery.ztree.excheck.js"></script>
	<script src="<%=path %>/web/zTree_v3-master/js/jquery.ztree.exedit.js"></script>

    <script type="text/javascript">

	var path = "<%=path%>";
		
    $(document).ready(function(){ 
		$("#add").colorbox({
			inline:true,
			width:"650px",
			close:"关闭",
			overlayClose:false  
		});
		$("#edit").colorbox({
			inline:true,
			width:"550px",
			close:"",
			overlayClose:false,
			onOpen:function(){    
			    var selId = getSelId();
			    if (selId==""){
					alert("请先选择一条数据！");
					$(this).colorbox.close();
					return;
				}
				$.ajax({
					type:"post",
					dataType:"json",
					url:path+"/SpotAction!getSpotInfo",
					data:{id:selId},
					success:function(data){  
					alert(data);
						$("#spotCode_edit").val(data.spotId);		
						$("#spotName_edit").val(data.spotName);
						$("#spotTel_edit").val(data.spotTel);
						$("#province_edit").val(data.province);
						$("#city_edit").val(data.city);  
						$("#town_edit").val(data.town); 
						$("#spotAddr_edit").val(data.spotAddr); 				 
					}
				});
			}
		});
		
	});

	function close_box(id){		   
		$("#"+id).colorbox.close();		
	}

	function  onSearch() {  
		 document.forms[0].action = "<%=path%>/SpotAction!spotList?flag=<%=flag%>";
		 document.forms[0].submit(); 
	}
	
	function  gotoPage(num) {  
		 document.forms[0].action = "<%=path%>/SpotAction!spotList?flag=<%=flag%>&pageNums="+num;
		 document.forms[0].submit(); 
	}
	
		//信息表单提交验证
	function checkForm(id){
		if($("#spotName"+id).val()==""){
			alert("名称不能为空");
			$("#spotName"+id).focus();
			return false;
		}
		if($("#spotCode"+id).val()==""){
			alert("编号号不能为空");
			$("#spotCode"+id).focus();
			return false;
		}
		return true;
	}
	function getSelId(){
	   var i=0;
	   var selId="";
	   $(":checkbox:checked").each(function(){  
	   	   i=i+1;
	       selId=$(this).val();  
	   });
	   if(i==0||i>1){
	   		return "";
	   }
	   return selId;
	} 
	
	function del(){
		var id = getSelId();	 
		if(id==""){
			alert("请选中要删除的信息");
		}else{
			if(confirm("您确定要删除选中信息，删除后不可恢复！")){ 
				document.forms[0].action = "<%=path%>/SpotAction!delSpot?id="+id; 
		    	document.forms[0].submit();  
			}
		}
	} 
	</script>
	<style type="text/css">
		table td{word-break: keep-all;white-space:nowrap;}
		table th{word-break: keep-all;white-space:nowrap;}
	</style>
	<script type="text/javascript">
		$(document).ready(function(){
			$(".table tr:even").addClass("active");
			
	        $(".table-margin tr").click(function(){
	        	$(".table tr").removeClass("success");
	        	$(".table tr:even").addClass("active");
	        	$(this).addClass("success");
	        });
		});
	</script>
</head>
<body>

    <div class="search-box row" style="padding-top:10px;border-bottom:1px solid #eee">  	
		<div class="col-md-12">			
	 		<div class="form-group">
		     	<span class="pull-left form-span">员工编号：</span>
		    </div>
	     	<div class="form-group">
		     	<input type="text" name="s_p_code" id="s_p_code"placeholder="请输入员工编号" class="form-control" value=""/>
	     	</div>
	     	<div class="form-group">
		     	<span class="pull-left form-span">员工名称：</span>
		    </div>
	     	<div class="form-group">
		     	<input type="text" name="s_p_name" id="s_p_name"placeholder="请输入员工名称" class="form-control" value=""/>
	     	</div>
  		 	 <div class="form-group btn-search">
	  		 	 <span></span>
	  		  	 <button class="btn btn-default" onclick="onSearch()" type="button" ><span class="glyphicon glyphicon-search"></span>查 询</button>
  		  	</div> 
		</div>
	</div>
	<div class="search-box row" style="padding-top:5px;">
		<div class="col-md-12">
	        <div class="btn-group pull-right" role="group" aria-label="...">
	  		  	 <a id="add" href="#add_box"><button class="btn btn-default" type="button" ><span class="glyphicon glyphicon-search"></span>新 增</button></a>
	  		  	 <a id="edit" href="#edit_box"><button class="btn btn-default" type="button" ><span class="glyphicon glyphicon-search"></span>修 改</button></a>
	  			 <a id="del" href="#" onclick="del()"><button class="btn btn-default" type="button" ><span class="glyphicon glyphicon-search"></span>删 除</button></a>
	  		</div>
	  	</div>
  	</div>
	<div class="clearfix"></div> 
		<div class="table-margin">
			<table class="table table-bordered table-header">
				<thead>
					<tr>
						<th>序号</th>
						<%
							for (int bi = 0; bi < qList.size(); bi++) {
									QueryVO vo = (QueryVO) qList.get(bi);
						%>
						<th><%=vo.getColName()%></th>
						<%
							}
						%>
					</tr>
				</thead>
				<tbody>
					<%
						PageVO pageVo = (PageVO) request.getAttribute("voResult");
							if (pageVo != null) {
								List<?> resultL = pageVo.getList();
								for (int ci = 0; ci < resultL.size(); ci++) {
					%>
					<tr align="center" onclick="setRowClass(this,'LT')">
						<td align="center"><%=ci + 1%></td>
						<%
							List<?> lDetail = (List<?>) resultL.get(ci);
										for (int si = 0; si < lDetail.size(); si++) {
						%>
						<td align="left"><%=(String) lDetail.get(si)%></td>
						<%
							}
						%>
					</tr>
					<%
						}
							}
					%>
				</tbody>
				<%
					if (pageVo != null) {
				%>
				<tfoot>
					<tr>
						<td colspan="17">
							<div class="pull-left">
								<nav>
								<ul class="pagination">
									<li><a href="#"
										onclick="gotoPage('<%=pageVo.getFirst_page()%>')"
										aria-label="首页"> <span aria-hidden="true">&laquo;</span>
									</a></li>
									<li><a href="#"
										onclick="gotoPage('<%=pageVo.getPrevious_page()%>')">前一页</a></li>
									<li><a href="#"
										onclick="gotoPage('<%=pageVo.getNext_page()%>')">下一页</a></li>
									<li><a href="#"
										onclick="gotoPage('<%=pageVo.getLast_page()%>')"
										aria-label="末页"> <span aria-hidden="true">&raquo;</span>
									</a></li>
									<li><a href="#">共<%=pageVo.getAll_size()%>条&nbsp;&nbsp;第<%=pageVo.getPresent_page()%>/<%=pageVo.getAll_page()%>页
									</a></li>
								</ul>
								</nav>
							</div>
						</td>
					</tr>
				</tfoot>
				<%
					}
				%>
			</table>
		</div>
	<div style="display:none;">
	   	<div id="add_box">
	   	<form class="form-horizontal" method="post" onsubmit="return checkForm('_add')" action="<%=path%>/SpotAction!saveSpot">   
	    	 <table class="table table-bordered table-header">
	    	 	<thead>  
		    	 	<tr>
			            <th colspan="6">维护配送点</th>               
				    </tr>
			    </thead>
			    <tbody>
			        <tr>
			            <td align="right">
			            	站点名称：
			            </td>
			            <td align="left">
			            	<input id="spotName_add" class='form-control' name="spot.spotName" type="text" />
			            </td>  
			            <td align="right">
			            	站点编码
			            </td >
			            <td align="left">
			            	<input id="spotCode_add"  class='form-control' name="spot.spotCode" type="text"  />
			            </td> 
			            <td align="right">
			            	电话：
			            </td>
						<td>
							<input id="spotTel_add"  class='form-control' name="spot.spotTel" type="text"  />
						</td> 
			        </tr>
			        <tr>
					    <td align="right">
					    	省：
					    </td>
						<td>
						     <input id="province_add"  class='form-control' name="spot.province" type="text"  />			     
						</td>
						<td align="right">
							市：
						</td>
						<td>
						     <input id="city_add"  class='form-control' name="spot.city" type="text"  />			     
						</td>
						<td align="right">
							县：
						</td>
						<td>
						     <input id="town_add"  class='form-control' name="spot.town" type="text"  />					     
						</td>
					</tr>
					<tr> 
					    <td align="right">
					    	详细地址：
					    </td>
						<td colspan="3">
							<input id="spotAddr_add"  class='form-control' name="spot.spotAddr" type="text"  />					     
						</td> 
						<td align="right">是否可用：</td>
						<td>
						     <select name="spot.activeFlag_add" id="activeFlag" class='form-control'  >  
								   <option value="">选择类别</option>
								   <option value="0">可用</option>
								   <option value="1">不可用</option>
							</select>
						</td> 
					</tr>
				</tbody>
				<tfoot>  
					<tr> 
						<td colspan="6" align="center">
						    <button class="btn btn-default" id="btnSave_edit" type="submit" ><span class="glyphicon glyphicon-ok"></span>保  存</button>
					 		<button class="btn btn-default" type="reset" onclick="close_box('add_box')" ><span class="glyphicon glyphicon-remove"></span> 取  消</button>
	          			</td> 
					</tr> 
				</tfoot>
			</table> 
	    	</form>
	   </div>
	</div>
	<div style="display:none;">
	   	<div id="edit_box">
	   	<form class="form-horizontal" method="post" onsubmit="return checkForm('_edit')" action="<%=path%>/SpotAction!updateSpot">   

	    	 <table class="table table-bordered table-header">
	    	 	<thead>  
		    	 	<tr>
			            <th colspan="6">维护配送点</th>               
				    </tr>
			    </thead>
			    <tbody>
			        <tr>
			            <td align="right">
			            	站点名称：
			            </td>
			            <td align="left">
			            	<input id="spotName_edit" class='form-control' name="spot.spotName" type="text" />
			            </td>  
			            <td align="right">
			            	站点编码
			            </td >
			            <td align="left">
			            	<input id="spotCode_edit"  class='form-control' name="spot.spotCode" type="text"  />
			            </td> 
			            <td align="right">
			            	电话：
			            </td>
						<td>
							<input id="spotTel_edit"  class='form-control' name="spot.spotTel" type="text"  />
						</td> 
			        </tr>
			        <tr>
					    <td align="right">
					    	省：
					    </td>
						<td>
						     <input id="province_edit"  class='form-control' name="spot.province" type="text"  />			     
						</td>
						<td align="right">
							市：
						</td>
						<td>
						     <input id="city_edit"  class='form-control' name="spot.city" type="text"  />			     
						</td>
						<td align="right">
							县：
						</td>
						<td>
						     <input id="town_edit"  class='form-control' name="spot.town" type="text"  />					     
						</td>
					</tr>
					<tr> 
					    <td align="right">
					    	详细地址：
					    </td>
						<td colspan="3">
							<input id="spotAddr_edit"  class='form-control' name="spot.spotAddr" type="text"  />					     
						</td> 
						<td align="right">是否可用：</td>
						<td>
						     <select name="activeFlag_edit" id="activeFlag" class='form-control'  >  
								   <option value="">选择类别</option>
								   <option value="0">可用</option>
								   <option value="1">不可用</option>
							</select>
						</td> 
					</tr>
				</tbody>
				<tfoot>  
					<tr> 
						<td colspan="6" align="center">
						    <button class="btn btn-default" id="btnSave_edit" type="submit" ><span class="glyphicon glyphicon-ok"></span>保  存</button>
					 		<button class="btn btn-default" type="reset" onclick="close_box('add_box')" ><span class="glyphicon glyphicon-remove"></span> 取  消</button>
	          			</td> 
					</tr> 
				</tfoot>
			</table> 
	    	</form>
	   </div>
	</div>

 <script type="text/javascript">
     var showMsg='<%=request.getAttribute("showMsg")%>';
     if(showMsg!="null"&&showMsg!=""){
        alert(showMsg);
     } 
    <%
    if(hmSearch!=null){
    Iterator iter = hmSearch.entrySet().iterator(); 
	while (iter.hasNext()) { 
	Entry entry = (Entry) iter.next();  
	if(!((String)entry.getValue()).equals("")){
	%>  
    document.all.<%=(String)entry.getKey()%>.value = "<%=(String)entry.getValue()%>"; 
	<%
	}}}
     %>
</script>
</body>
</html>
